package com.javaspeak.designpatterns.go4.structural.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * Abstract class that implements HtmlElement to provide functionality for the
 * getHtmlElements() method.  Does not implement getHtml().  Both TableElement
 * and TextElement extend AbstractHtmlElement.  The reason TextElement extends
 * AbstractHtmlElement is that a sub class of TextElement may wish to become
 * composite and make use of the list of <HtmlElement>.  For example a more
 * sophisticated implementation of TextElement may wish to include elements
 * such as "bold" and "underline".
 *
 * @author John Dickerson
 */
public abstract class AbstractHtmlElement implements HtmlElement {

    List<HtmlElement> htmlElements = new ArrayList<HtmlElement>();

    /* (non-Javadoc)
     * @see com.javaspeak.designpatterns.go4.structural.composite.HtmlElement#
     *      getHtmlElements()
     */
    @Override
    public List<HtmlElement> getHtmlElements() {

        return htmlElements;
    }


    /* (non-Javadoc)
     * @see com.javaspeak.designpatterns.go4.structural.composite.
     *      HtmlElement#getHtml()
     */
    @Override
    public abstract String getHtml();
}
